package com.ruoyi.project.newhope.user.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.newhope.user.mapper.NewHopeUserMapper;
import com.ruoyi.project.newhope.user.domain.NewHopeUser;
import com.ruoyi.project.newhope.user.service.INewHopeUserService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 用户Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-02-08
 */
@Service
public class NewHopeUserServiceImpl implements INewHopeUserService 
{
    @Autowired
    private NewHopeUserMapper newHopeUserMapper;

    /**
     * 查询用户
     * 
     * @param id 用户ID
     * @return 用户
     */
    @Override
    public NewHopeUser selectNewHopeUserById(Long id)
    {
        return newHopeUserMapper.selectNewHopeUserById(id);
    }

    /**
     * 查询用户列表
     * 
     * @param newHopeUser 用户
     * @return 用户
     */
    @Override
    public List<NewHopeUser> selectNewHopeUserList(NewHopeUser newHopeUser)
    {
        return newHopeUserMapper.selectNewHopeUserList(newHopeUser);
    }

    /**
     * 新增用户
     * 
     * @param newHopeUser 用户
     * @return 结果
     */
    @Override
    public int insertNewHopeUser(NewHopeUser newHopeUser)
    {
        newHopeUser.setCreateTime(DateUtils.getNowDate());
        return newHopeUserMapper.insertNewHopeUser(newHopeUser);
    }

    /**
     * 修改用户
     * 
     * @param newHopeUser 用户
     * @return 结果
     */
    @Override
    public int updateNewHopeUser(NewHopeUser newHopeUser)
    {
        newHopeUser.setUpdateTime(DateUtils.getNowDate());
        return newHopeUserMapper.updateNewHopeUser(newHopeUser);
    }

    /**
     * 删除用户对象
     * 
     * @param id 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteNewHopeUserByIds(String id)
    {
        return newHopeUserMapper.deleteNewHopeUserByIds(Convert.toStrArray(id));
    }

    /**
     * 删除用户信息
     * 
     * @param id 用户ID
     * @return 结果
     */
    @Override
    public int deleteNewHopeUserById(Long id)
    {
        return newHopeUserMapper.deleteNewHopeUserById(id);
    }

    @Override
    public NewHopeUser selectUserByLoginName(String username) {
        return newHopeUserMapper.selectUserByLoginName(username);
    }
}
